<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>
<head>
    <base href="<%=basePath%>">
    <title></title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <link rel="stylesheet" type="text/css" href="css/edittable.css"  ></link>
    <link rel="stylesheet" type="text/css" href="css/validate.css"  ></link>
    <script type="text/javascript"  src="js/jquery-1.8.0.js"></script>
    <style>
        .info{
            color: green;
            font-weight: bold;
        }
        .error{
            color: red;
            font-weight: bold;
        }

    </style>
    <script>
        $(function(){
            $("input[type=text]").focus(function(){
                $(this).addClass("input_focus");
            }).blur(function(){
                $(this).removeClass("input_focus");
            });

            $(".form_btn").hover(function(){
                    $(this).css("color","red").css("background","#6FB2DB");},
                function(){
                    $(this).css("color","#295568").css("background","#BAD9E3");
                });
        });
        $(function() {
            $("#rolename").keyup(function () {
                var s = $("#rolename").val();
                var e = /^^[\S]{2,15}$/;
                if (e.test(s) == false) {
                    $("#regname").html("校验失败，格式错误").removeClass().addClass("error");
                } else {
                    $.ajax({
                        url: "RoleServlet",
                        type: "post",
                        data: {
                            flag: "checkreg", username: s
                        },
                        success: function (data) {
                            if (data == "1")
                                $("#regname").html("角色已存在").removeClass().addClass("error");
                            if (data == "0")
                                $("#regname").html("角色可用").removeClass().addClass("info");
                        }
                    });
                }
            });
        });
        $(function () {
            $("#sub").click(function () {
                var a=$("label#regname").text();
                var a1="校验失败，格式错误";
                var a2="角色已存在";
                if(a==a1 ||a==a2)
                    return false;
                else return confirm("确认提交吗");
            }) ;
        });

    </script>
</head>
<body>
<div class ="div_title">
    <div class="div_titlename"> <img src="images/san_jiao.gif" ><span>角色修改</span></div>
</div>
<form action="RoleServlet" method="post" >
    <input type="hidden" name="flag" value="update" />
    <input type="hidden" name="id" value="${param.id}" />
    <table class="edit_table" >
        <tr>
            <td class="td_info">角色:</td>	<td class="td_input">
            <input type="text" name="rolename" id="rolename" class="txtbox" value="${param.rolename}" />
            <label id="regname"></label> </td>
            <td><label>2-15个非空字符</label></td>
        </tr>
        <tr>
            <td class="td_info">备注信息:</td>	<td>
            <textarea rows="4" cols="24" name="des" class="txtarea"  >${param.des}</textarea>
        </td>
        </tr>

        <tr>
            <td class="td_info"> </td>
            <td>
            <input class="form_btn" type="submit" id="sub" value="提交" />
            <input type="reset"  class="form_btn" value="重置" />
            <label>${msg}</label>
        </td>	<td class="info"> &nbsp;</td>
        </tr>
    </table>
</form>
</body>
</html>
